package com.guoyansoft.controller;

import com.guoyansoft.config.R;
import com.guoyansoft.model.pojo.Shop;
import com.guoyansoft.model.pojo.ShopType;
import com.guoyansoft.model.service.ShopTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/shopType")
public class ShopTypeController {
    @Autowired
    private ShopTypeService shopTypeService;

    @RequestMapping("/queryByPage")
    public R queryByPage(Integer curPage, Integer pageSize
                        ) {
        Map<String,Object> params=new HashMap<>();
        params.put("startIndexKey",(curPage-1)*pageSize);
        params.put("pageSizeKey",pageSize);
        R r = shopTypeService.queryByPage(params);
        return r;
    }
    @RequestMapping("/dropBatch")
    public R dropBatch(Integer[] id) {

        boolean flag = shopTypeService.dropBatch(id);

        return flag?R.suc():R.fail();
    }

    @RequestMapping("/save")
    public R save(ShopType shopType) {
        boolean flag = shopTypeService.save(shopType);
        return flag?R.suc():R.fail();
    }
    @RequestMapping("/update")
    public R update(ShopType emp,Integer shopId){
        boolean flag = shopTypeService.update(emp);
        return flag?R.suc():R.fail();
    }

    @RequestMapping("/queryById")
    public R queryById(Integer id){
        ShopType shopType = shopTypeService.queryById(id);
        return shopType==null?R.suc():R.fail();
    }
}
